Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

139
Vistas
Unable to declare onComplete function in Conf.ts >>Getting error -- Type '(passed: any) => void' is not assignable to type '() => void'.ts(2322)

I am working on a Protractor - browserstack framework from scratch.

While using onComplete function as mentioned on the site in conf.ts - https://automate.browserstack.com/dashboard/v2/quick-start/get-started#introduction

 // Code to mark the status of test on BrowserStack based on test assertions
      onComplete: function (passed) {
        if (!passed) {
          browser.executeScript('browserstack_executor: {"action": "setSessionStatus", "arguments": {"status":"failed","reason": "At least 1 assertion has failed"}}');
        }
        if (passed) {
          browser.executeScript('browserstack_executor: {"action": "setSessionStatus", "arguments": {"status":"passed","reason": "All assertions passed"}}');
        }
      }

I'm getting below error on Console

*Debugger attached. conf.ts:87:1 - error TS2322: Type '(passed: any) => void' is not assignable to type '() => void'. 87 onComplete: function (passed) {

node_modules/protractor/built/config.d.ts:410:5
 410     onComplete?: () => void;
         ~~~~~~~~~~
 The expected type comes from property 'onComplete' which is declared here on type 'Config'*



Can someone help me understand how to resolve this error?
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This looks like a bug in the type definitions for onComplete. In the usage it looks like the onComplete is passed a variable. See: https://github.com/angular/protractor/blob/master/lib/frameworks/jasmine.js#L109-L115

const originalOnComplete = runner.getConfig().onComplete;

jrunner.onComplete(async(passed) => {
  try {
    if (originalOnComplete) {
      await originalOnComplete(passed);
    }

Although you could create a TypeScript config.ts, it might be better to create a config.js file. Using config.ts could also run into problems when you want to reference the browser object. The browser variable would have to be brought in via require instead of import.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda